<#include "/common/pagerForm.html">
<form rel="pagerForm" method="post" action="" class="pageForm required-validate" onsubmit="return navTabSearch(this)">
<input type="hidden" id="timeInterval" name="timeInterval" value="${timeInterval!''}" /><!-- 上次定时器记录参数 -->
<div class="pageHeader">
    <div class="searchBar">
        <ul class="searchContent">
            <li><label><@label key="workCenterCode.C,colon">工作中心编号:</@label></label> 
                <input id="workCenterGrp.workCenterCode" name="workcenterCode" type="text" suggestFields="workCenterCode,workCenterText" 
                postField="workCenterCode" suggestUrl="${rc.getContextPath()}/manage/workCenter/workCenterSuggest" lookupGroup="workCenterGrp" 
                autocomplete="off" value="${condition.workcenterCode!''}" />
            </li>
            <li ><label><@label key="workUnit.C,colon">作业单元：</@label></label>
                 <input class="look" id="workUnitLookup.workUnitText" name="workunitCode" type="text" value="${condition.workunitCode!''}" postField="workUnitCode" suggestFields="workUnitCode,workUnitText" 
                    suggestUrl="${rc.getContextPath()}/manage/workUnit/workUnitSuggest" lookupGroup="workUnitLookup"/>
                 <a class="btnLook" href="${rc.getContextPath()}/manage/workUnit/workUnitLookUp?lookupType=radio" rel="workUnitLookup_dialog" title="<@label key='select.C,workUnit.C'>选择作业单元</@label>" lookupGroup="workUnitLookup" ></a>
            </li>
            <li>
                <label><input type="checkbox" name="flushFlag" <#if condition.flushFlag?? && condition.flushFlag==1>checked</#if> value="1"/>刷新(秒)</label>
                <input type="text"  name="time" value="${condition.time!''}" <#if !condition.flushFlag?? || condition.flushFlag!=1>readonly</#if> class="digits" min="1" />         
            </li>
                    
        </ul>
        <ul class="searchContent">
            <li>
                <label><@label key="warehouse.C,colon">线边仓库：</@label></label>
                <select  id="mm_warehouseCode" class="allyselect valid" ref="storageLocation" 
                postField="warehouseCode"  name="warehouseCode" refUrl="${rc.getContextPath()}/manage/warehouse/warehouseChange">
                 <option value=""><@label key="selected_first.C">请选择</@label></option>
                 <#list warehouses as warehouse>
                     <option flag="${warehouse.locationManageFlag}" value='${warehouse.warehouseCode}'
                     <#if condition.warehouseCode?? && condition.warehouseCode == warehouse.warehouseCode> selected="selected"</#if>> ${warehouse.warehouseCode}-${warehouse.warehouseText}</option>
                  </#list>
                </select>
            </li>
            <li>
                <label><@label key="storageLocation.C,colon">线边库位：</@label></label>
                <select selectedValue="${condition.storageLocationCode!''}" id="storageLocation" field="storageLocationCode" name="storageLocationCode" label="storageLocationText" >
                    <option value=""><@label key="selected_first.C">请选择</@label></option>
                </select>
            </li>
            <li class="query">
                <div class="buttonActive">
                    <div class="buttonContent">
                        <button type="submit"><@label key="query.B">查询</@label></button>
                    </div>
                </div>
            </li>
        </ul>
    </div>
</div>           
</form>
<div class="pageContent">
    <table class="table border" width="100%" layoutH="130" style="overflow: scroll;">
        <thead>
            <tr>
                <th width="100"><@label key="requirementNum.C">需求编号</@label></th>                   
                <th width="100" orderField="materialCode"<#if (page.orderField?? && page.orderField == 'materialCode')>class="${page.orderDirection!''}"</#if>><@label key="materialCode.C">物料编号</@label></th>
                <th width="100"><@label key="materialText.C">物料描述</@label></th>
                <th width="100"><@label key="distributionQuantity.C">需求数量</@label></th>
                <th width="100"><@label key="actualQuantity.C">已发数量</@label></th>
                <th width="100" orderField="createDateTime"<#if (page.orderField?? && page.orderField == 'createDateTime')>class="${page.orderDirection!''}"</#if>><@label key="requirementCreate.C">需求产生时间</@label></th>
                <th width="100"><@label key="expectedArrivalDateTime.C">期望到货时间</@label></th>
                <th width="100"><@label key="distributionModeText.C">配送方式描述</@label></th>
                <th width="100"><@label key="workCenter.C">工作中心</@label></th>
                <th width="100"><@label key="workUnit.C">作业单元</@label></th>
                <th width="100"><@label key="theLine.C,warehouse.C">线边仓库</@label></th>
                <th width="100"><@label key="theLine.C,storageLocation.C">线边库位</@label></th>
                <th width="100"><@label key="distributionUser.C">配送人员</@label></th>
            </tr>
        </thead>
        <tbody id='tbody'>
        <#if page??><#if (page.data?size>0)> <#list page.data as distribution>
            <tr>
                <td>${distribution.requirementNum!''}</td>
                <td>${distribution.materialCode!''}</td>
                <td>${distribution.materialText!''}</td>
                <td>${distribution.distributionQuantity!''}</td>
                <td>${distribution.actualQuantity!''}</td>
                <td>${(distribution.createDateTime?string("yyyy-MM-dd HH:mm:ss"))?if_exists}</td>
                <td>${(distribution.expectedArrivalDateTime?string("yyyy-MM-dd HH:mm:ss"))?if_exists}</td>
                <td>${distribution.distributionModeText!''}</td>
                <td>${distribution.workCenterCode!''}</td>
                <td>${distribution.workUnitCode!''}</td>
                <td>${distribution.warehouseCode!''}</td>
                <td>${distribution.locationCode!''}</td>
                <td>${distribution.distributionUser!''}</td>
            </tr></#list> <#else>
            <tr>
                <td colspan="13" class="noData">======<@label key="noListData.C">列表无数据</@label>=====</td>
            </tr>
            </#if><#else>
            <tr>
                <td colspan="13" class="noData">======<@label key="noListData.C">列表无数据</@label>=====</td>
            </tr>
            </#if>
        </tbody>
    </table>
    <#include "/common/panelBar.html">
</div>


<script type="text/javascript">
$(function(){
	//先清除上次的定时器
	if($("input#timeInterval", reqirementKanbanPanel).val())
		   window.clearInterval($("input#timeInterval", reqirementKanbanPanel).val());
	var kanbanInterval = _kanbanReflush();
	$("input[name='flushFlag']", reqirementKanbanPanel).change(function(){
		if($(this).is(':checked')){
			$("input[name='time']", reqirementKanbanPanel).addClass("required");
			$("input[name='time']", reqirementKanbanPanel).removeAttr("readonly")
			$("input[name='time']", reqirementKanbanPanel).removeClass("readonly");
		}else{
			$("input[name='time']", reqirementKanbanPanel).removeClass("required");
			$("input[name='time']", reqirementKanbanPanel).addClass("readonly")
			$("input[name='time']", reqirementKanbanPanel).attr("readonly", "readonly");
			if(kanbanInterval){
				window.clearInterval(kanbanInterval);
			}
		}
	});
})

var reqirementKanbanPanel = navTab.getPanel("${navTabId!''}");
function _kanbanReflush(){
	var time = $("input[name='time']", reqirementKanbanPanel).val();
	if($("input[name='flushFlag']", reqirementKanbanPanel).is(':checked') && time > 0){
		var timeInterval =  setInterval(function(){
			//如果看板tab是活动tab（当前tab）,则进行刷新
			if(navTab._indexTabId("${navTabId!''}") == navTab._currentIndex)
			    navTab.reloadFlag("${navTabId!''}");
		}, time*1000);
		$("input#timeInterval", reqirementKanbanPanel).val(timeInterval);
		return timeInterval;
	}
}
</script>
